home *** CD-ROM | disk | FTP | other *** search
- ; CUNIX.SCR
- ;
- ; Christine M. Gianone, CUCCA/AcIS, October 1991
- ;
- ; An MS-DOS Kermit script for easy access to Columbia University's
- ; CUNIX systems. It navigates through ROLMphone and terminal server
- ; and logs the user in.
- ;
- ; You can run this script from within Kermit by typing TAKE CUNIX.SCR,
- ; but it is designed for more convenient use by running Batch files
- ; from the DOS command line, for example CUNIXA.BAT
- ;
- ; CUNIXA myuserid
- ;
- ; userid and password can be given on the DOS command
- ; line, for example:
- ;
- ; C:\>cunixa myuserid mypassword
- ;
- ; The "cunixa" DOS command requires the following CUNIXA.BAT file to
- ; reside in the user's PATH:
- ;
- ; @echo off
- ; kermit def userid %1, def passwd %2, def host cunixa, take cunix.scr, stay
- ;
- ; CUNIX.SCR prompts for user ID and password if these are not
- ; already defined, then connects through the CBX, automatically detecting
- ; either a regular DCM phone or a 244PC, and logs in to the host.
- ;
- ; IMPORTANT: CUNIX.SCR assumes user's shell prompt is "$ " or "% ".
- ;
- ; Requires MS-DOS Kermit 3.11 or later.
-
- if not < version 311 goto OK
- echo Sorry, version 3.11 or later of MS-DOS Kermit is required.
- stop
-
- :OK
-
- ;;; NOTE: If your UNIX system prompt is not "$ " or "% ",
- ;;; you must define the "myprompt" variable to say what it is, as in the
- ;;; following commented-out command for a "cunixa: " prompt:
- ;
- ; define myprompt {cunixa: }
-
- ; Macro to issue an error message and stop.
- ;
- define errstop echo \%1, hangup, stop
-
- ; Define GETOUT macro to log out from UNIX, hang up, and exit Kermit.
- ;
- define getout out \13,-
- inp 8 \m(prompt),-
- if succ out exit \59 exit\13,-
- hangup,-
- exit
-
- set key \2320 {\Kgetout} ; Assign GETOUT macro to Alt-Q.
-
- ; Action starts here
- ;
- if def passwd cls ; for security...
- def \%9 ; "Thank you" flag.
-
- if def host goto ASKUID
- :XHOST
- ask \%8 {Which CUNIX system: }
- if not def \%8 goto XHOST
- assign host \%8
- def \%9 Thank you.
-
- :ASKUID
- if def userid goto askpw
- :XUID
- ask \%8 {Please type your user ID, then press the Enter key: }
- if not def \%8 goto XUID
- assign userid \%8
- def \%9 Thank you.
-
- :ASKPW
- if def passwd goto thanks
- :XPWD
- askq \%8 -
- {Please type your password (it won't echo), then press the Enter key: }
- if not def \%8 goto XPWD
- assign passwd \%8
- def \%9 Thank you.
-
- :THANKS
- def \%8 ; Erase password from memory
- if def \%9 echo \%9 ; Be polite
- def \%9
- echo
-
- ; Communication and script settings
- ;
- set parity none ; Don't use parity.
- set display 7 ; But don't display it either.
- set flow xon/xoff ; Use Xon/Xoff flow control.
- set handsh none ; No handshake.
- set duplex full ; Full duplex, remote echo.
- set input timeout proceed ; This enables IF SUCCESS and IF FAILURE.
- set input case ignore ; Don't care about alphabetic case.
- hangup ; Hang up any current data connection.
- pause
-
- ; Try 3 times to get Rolmphone's attention.
- ;
- :LOOP
- output \13 ; Output a carriage return.
- :CBX ; Assume DCM with CALL, DISPLAY OR MODIFY?
- input 6 MODIFY? ; Look for CBX prompt.
- if failure goto RP244PC ; If not found, go try 244PC.
- echo \13CBX dialing... ; It's the CBX, tell the user.
- output CALL CUNIX\13 ; Dial CUNIX.
- input 30 COMPLETE ; Get CALL COMPLETE message
- if failure errstop -
- {Sorry, the CUNIX terminal server does not answer. Please try again later.}
- goto good ; Got connected, go login
-
- :RP244PC ; Let's see if it's a 244PC
- output \13AT\13 ; Give the Hayes modem AT command
- input 5 OK ; Look for Hayes OK response.
- if failure goto RETRY ; Not found, try again.
- echo 244PC dialing... ; It's 244PC, tell the user.
- output ATDT[CUNIX]\13 ; Make a data call to "[CUNIX]".
- input 30 CONNECT ; Look for modem's confirmation.
- if success goto GOOD
-
- :RETRY
- if count goto LOOP
-
- ; Get here when there is no communication after 3 tries.
- ;
- echo
- echo { Sorry, I can't seem to communicate with your ROLMphone.}
- echo { Your port is \v(port), your speed is \v(speed).}
- echo { If these parameters are not correct, use Kermit's SET PORT}
- echo { and SET SPEED commands to correct them and try again.}
- echo { Otherwise, please check the data cable between your PC}
- echo { and the ROLMphone and try again.}
- echo
- hangup
- stop
-
- :GOOD ; We got through, one way or the other.
- ;
- ; Send carriage returns for speed recognition. Try up to 7 times
- ; to get terminal server prompt.
- ;
- pause
- set count 7
-
- :AGAIN
- output \13
- input 1 >
- if success goto TSPROMPT ; If found, proceed with login process,
- if count goto again ; otherwise continue the loop.
- errstp {Failure to get terminal server prompt, try again later.}
-
- :TSPROMPT
- ;
- ; Got terminal server prompt, select host, and wait for login: prompt.
- ;
- output \m(host)\13 ; Ask for the desired host.
- input 20 login:
- if fail errstop {Failure to get login prompt, please try again later.}
-
- :LOGIN
- ;
- ; Got "login:" prompt, send user ID and look for "Password:" prompt.
- ;
- output \m(userid)\13 ; Send user ID, followed by CR.
- input 20 Password: ; Wait up to 5 seconds for "Password:" prompt.
- if fail errstop {Failure to get password prompt, please try again later.}
-
- ; Send user's password, then wait for shell prompt.
- ;
- output \m(passwd)\13 ; Send password.
- define passwd ; Erase from memory.
-
- ; Now try to get the shell prompt.
- ;
- if not def myprompt goto GUESS ; No custom prompt, must guess.
-
- assig prompt \m(myprompt) ; Custom prompt defined.
- input 60 \m(prompt) ; Look for it.
- if success goto TERM ; Got it. Go start application.
- output \26 ; Didn't get it, try to Ctrl-Z out of notes.
- input 10 \m(prompt) ; Look for prompt again.
- if success goto TERM ; Got it...
- output \26 ; Didn't get it, try one more Ctrl-Z.
- input 10 \m(prompt) ; Look again.
- if success goto TERM ; Got it...
- errstop {Sorry, the system is too busy. Please try again later.}
-
- :GUESS
- ;
- ; No custom prompt. Look for standard sh, ksh, or csh prompt.
- ;
- input 60 \13\10$\32 ; Look for "$ " (ksh or sh).
- if success goto TERMD ; Got it. Go start application.
- reinput 1 \13\10%\32 ; Try for "% " C-Shell prompt.
- if success goto TERMP
- output \26 ; Didn't get it, try to Ctrl-Z out of notes.
- input 10 \13\10$\32 ; Look for prompt again.
- if success goto TERMD ; Got it...
- reinput 1 \13\10%\32 ; Try for "% " C-Shell prompt.
- if success goto TERMP
- output \26 ; Didn't get it, try one more Ctrl-Z.
- input 10 \13\10$\32 ; Look again.
- if success goto TERMD ; Got it...
- reinput 1 \13\10%\32 ; Try for "% " C-Shell prompt.
- if success goto TERMP
- errstop {Sorry, the system is too busy. Please try again later.}
-
- :TERMD
- assig prompt \13\10$\32
- goto TERM
- :TERMP
- assig prompt \13\10%\32
- :TERM
- ;
- ; User is logged in and has system prompt. Now set terminal type.
- ; The tset command should work for any shell.
- ;
- set input echo off
- set terminal type vt320
- output eval `tset -sQ vt300` \59 echo Hi!\13
- input 30 \m(prompt)
-
- echo
- echo You are now logged in to \m(host).
- echo Use Alt-x to get back to Kermit.
- echo Use Alt-q to log out from \m(host) and return to DOS.
- echo Press any key to start...
- echo
- pause 9999 ; Wait for them to press a key.
- output \13 ; Send a carriage return.
- connect ; Begin terminal emulation.
-
- ; If they escaped back, check the carrier detect signal to see if they
- ; logged out, issue appropriate messages in each case.
- ;
- wait 1 CD
- if succ goto WARN
- echo
- echo { Your connection to \m(host) is broken.}
- echo { Type EXIT (then Enter) to leave Kermit and go back to DOS.}
- stop
-
- :WARN
- echo
- echo Warning: back at PC, but connection to \m(host) might still be active.
- echo
- echo { Type CONNECT (then press the Enter key) to go back to \m(host).}
- echo { Type HANGUP (then Enter) to cancel your \m(host) session.}
- echo { Type EXIT (then Enter) to leave Kermit and go back to DOS.}
- echo
- stop
-